/*
使用方法：
mAlert("这是一段测试文字", () => {
	console.log('点击了确认');
})
或
mAlert({
	content: '这是一段测试文字',
	okClose: false, // 用来控制点击确认和遮罩是否关闭对话框
	onOk: close => {
		console.log('111');
		close();
	}
})
*/

import {createApp} from "vue";
import AlertComponent from "./index.vue";


const mAlert = (options = '', onOk = null) => {
	if(typeof options != 'object') {
		options = {
			content: options,
			onOk: onOk
		}
	}
	const promptApp = createApp(AlertComponent, options);
	// 显示弹窗
	showPrompt(promptApp)
}

const showPrompt = (app) => {
	const oFrag = document.createDocumentFragment();
	const vm = app.mount(oFrag);
	document.body.appendChild(oFrag);
	vm.open();
}

export default mAlert;









